<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php include 'logincheck.php'?>
<html>
<head>
<meta name="robots" content="noindex, nofollow">
<title>Edit or Delete articles</title>
<?php
include 'head.php';
?>
</head>
<body>
<?php
include 'nav.php';
?>
<div id="wrapper">
	<div id="content">
<div class="panel">You are now logged in | <a href="post">New</a> | <a href="edit">Edit</a> | <a href="alert">Alert</a> | <a href="logout">Logout</a></div>
	<h1>Edit</h1>
	<?php
	include 'connect.php';
	
	mysql_select_db($db, $con);
	
	$query  = "SELECT * FROM {$table} ORDER BY ID DESC";
	$result = mysql_query($query) or die(mysql_error());

	while($row = mysql_fetch_assoc($result)) {
		echo "<div class='entry'>"
			 ."<h3>".$row['Name']."</h3>"
			 ."<small>".$row['Date']."</small> [ <a href='post?id=".$row['ID']."'>Edit</a> ] [ <a href='javascript:del(".$row['ID'].")'>Delete</a> ]</div>";
	}
	mysql_close($con);
	?>
	</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
function del(id){
	if ( confirm ( "Are you sure?" ) ) {
		url = "delete?id=" + id;
		$(function(){
			$.post( url, { id: id},
			function( data ) {
				location.reload();
			}
    );
		});
	}
}
</script>
<?php
include 'footer.php';
?>
</body>
</html>
	